package leetcode.dp;

/**
 * @author mazouri
 * @create 2021-09-20 23:50
 */
public class _122_maxProfit {


    public int maxProfit(int[] prices) {
        int res = 0;
        for (int i = 0; i < prices.length - 1; i++) {

            if (prices[i] < prices[i + 1]) {
                res += prices[i + 1] - prices[i];
            }
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(new _122_maxProfit().maxProfit(new int[]{7, 1, 5, 3, 6, 4}));
    }
}
